home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 16
/
AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso
/
pd
/
anwendungen
/
xpk_source
/
test
/
testmemexamine.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-08-27
|
3KB
|
132 lines
#define NAME "testMemExamine"
#define DISTRIBUTION "(Freeware) "
#define REVISION "3"
#define SDI_ENDCODE_NOCTRLC
/* Programmheader
Name: testMemExamine
Author: SDI
Distribution: Freeware
Description: tests Xpk Examine function
Compileropts: -
Linkeropts: -l xpkmaster
1.1 06.12.96 : fixed for new includes, added new WriteXpkFib
1.2 15.04.97 : included WriteXpkFib.c
1.3 19.12.97 : added new flags
*/
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/xpkmaster.h>
#include <exec/memory.h>
#include "SDI_defines.h"
#include "PrintFlags.c"
struct Library *XpkBase = 0;
ULONG DosVersion = 37;
STRPTR buf = 0;
BPTR fh = 0;
struct RDArgs *rda = 0;
struct FileInfoBlock *fib = 0;
struct XpkFib *xfib = 0;
#define PARAM "FILENAME/A"
void WriteXpkFib(struct XpkFib *xfib)
{
STRPTR a = 0;
switch(xfib->xf_Type)
{
case 0: a = "XPKTYPE_UNPACKED"; break;
case 1: a = "XPKTYPE_PACKED"; break;
case 2: a = "XPKTYPE_ARCHIVE"; break;
}
if(a)
VPrintf("xf_Type : %s\n", &a);
else
VPrintf("xf_Type : %ld\n", &xfib->xf_Type);
VPrintf(
"xf_ULen : %ld\n"
"xf_CLen : %ld\n"
"xf_NLen : %ld\n"
"xf_UCur : %ld\n"
"xf_CCur : %ld\n"
"xf_ID : %lx", &xfib->xf_ULen);
a = (STRPTR) &xfib->xf_ID;
VPrintf(" (%.4s)\n", &a);
a = xfib->xf_Packer;
VPrintf(
"xf_Packer : %s\n", &a);
VPrintf(
"xf_SubVersion: %d\n"
"xf_MasVersion: %d\n"
"xf_Flags : ", &xfib->xf_SubVersion);
{
ULONG i = xfib->xf_Flags;
PrintFlag(&i, XPKFLAGS_PASSWORD, "XPKFLAGS_PASSWORD");
PrintFlag(&i, XPKFLAGS_KEY16, "XPKFLAGS_KEY16");
PrintFlag(&i, XPKFLAGS_KEY32, "XPKFLAGS_KEY32");
PrintFlag(&i, XPKFLAGS_NOSEEK, "XPKFLAGS_NOSEEK");
PrintFlag(&i, XPKFLAGS_NONSTD, "XPKFLAGS_NONSTD");
PrintEndFlag(i, xfib->xf_Flags);
}
VPrintf(
"xf_Head : %04lx%04lx%04lx%04lx\n"
"xf_Ratio : %ld\n", &xfib->xf_Head[0]);
}
void main(void)
{
UBYTE errbuf[XPKERRMSGSIZE+1];
STRPTR filename;
if(!(rda = ReadArgs(PARAM, (LONG *) &filename, 0)) ||
!(xfib = (struct XpkFib *) AllocMem(sizeof(struct XpkFib), MEMF_ANY|MEMF_CLEAR)) ||
!(XpkBase = OpenLibrary(XPKNAME, 0)))
End(RETURN_FAIL);
if(XpkExamineTags(xfib, XPK_InName, filename, XPK_GetError, errbuf,
TAG_DONE))
{
STRPTR a = errbuf;
VPrintf("Can't XpkExamine: %s\n", &a);
End(RETURN_FAIL);
}
WriteXpkFib(xfib);
if(!(fh = Open(filename, MODE_OLDFILE)) ||
!(fib = (struct FileInfoBlock *) AllocDosObject(DOS_FIB, 0)) ||
!(ExamineFH(fh, fib)) ||
!(buf = (STRPTR) AllocMem(fib->fib_Size, MEMF_ANY)) ||
Read(fh, buf, fib->fib_Size) != fib->fib_Size)
End(RETURN_FAIL);
if(XpkExamineTags(xfib, XPK_InBuf, buf, XPK_InLen, fib->fib_Size,
XPK_GetError, errbuf, TAG_DONE))
{
STRPTR a = errbuf;
VPrintf("Can't XpkExamine: %s\n", &a);
End(RETURN_FAIL);
}
WriteXpkFib(xfib);
End(RETURN_OK);
}
void end(void)
{
if(fh) Close(fh);
if(xfib) FreeMem(xfib, sizeof(struct XpkFib));
if(buf) FreeMem(buf, fib->fib_Size);
if(XpkBase) CloseLibrary(XpkBase);
if(fib) FreeDosObject(DOS_FIB, fib);
if(rda) FreeArgs(rda);
}